//Philip Pilosi
import java.util.ArrayList;
//import java.util.Map;
//import java.util.HashMap;


//Only has test country filter currently!!!


public class Filters
{
    //Instance Variables.
    public boolean countryFilter;
    public boolean sexFilter;
    public boolean ageFilter;
    
    //Filter containers.
    public ArrayList<String> countryList; //List of countries
    public int sexFilterValue;//0 == Male & Female || 1 == Female || 2 == Male
    public int[] ageFilterValue;
    
    
    
    public Filters()
    {
        countryFilter = false;
        sexFilter = false;
        ageFilter = false;
        
        
        countryList = new ArrayList<String>();
        sexFilterValue = 0;
        ageFilterValue = new int[2];
        ageFilterValue[0] = 0;
        ageFilterValue[1] = 1000;
    }
    
    public void addCountry(String country)
    {
    	if(country.equals("")) {
    		countryFilter = false;
    	}
    	else if(!countryList.contains(country))
        {
            countryList.add(country);
            countryFilter = true;
            System.out.println("Added country: " + country);
        }
    }
    
    public void removeCountry(String country)
    {
        if(countryList.contains(country))
        {
            countryList.remove(country);
            if(countryList.size() == 0)
            {
                countryFilter = false;
            }
        }
    }
    
    public void setSexValue(int value)
    {
        sexFilterValue = value;
    }
    
    public void setLowerAgeBound(int value)
    {
        ageFilterValue[0] = value;
    }
    
    public void setUpperAgeBound(int value)
    {
        ageFilterValue[1] = value;
    }
    
    public void onOffSex()
    {
        sexFilter = !sexFilter;
    }
    
    public void onOffAge()
    {
        ageFilter = !ageFilter;
    }
    
  //Generate a title from filter
	public String generateTitle() {
		String temp = "Results for";
		
		//----
		if(sexFilterValue > 0)
			temp += " " + GLOBAL.getSexString(sexFilterValue);
		
		//----
		if(ageFilterValue[0] == ageFilterValue[1])
			temp += " Age " + ageFilterValue[0];
		else
			temp += " Ages " + ageFilterValue[0] + "-" + ageFilterValue[1];
		
		//----
		temp += " in ";
		if(!countryFilter)
			temp += "All Countries";
		else {
			for(int x=0; x<countryList.size(); ++x) {
				temp += countryList.get(x) + " ";
			}
		}
		
		return temp;
	}
}
